package com.bracketbird.server.services;


import com.bracketbird.client.service.rtc.*;
import com.bracketbird.server.dao.*;
import com.bracketbird.server.repository.tournament.*;
import com.bracketbird.clientcore.appcontrol.*;
import com.bracketbird.clientcore.service.*;


/**
 *
 */
public class RTCDeleteEventActionHandler extends AbstractActionHandler implements ActionHandler<RTCDeleteEventsAction, VoidResult> {


    public VoidResult execute(RTCDeleteEventsAction  action) throws ApplicationException {

        TournamentRepository repos = new TournamentRepository();

        try {
            PMF.startTransaction();
            repos.deleteBadEvents(action.getLastDone().getTournamentId(), action.getLastDone().getEventLogId());
            PMF.commitTransaction();

            return new VoidResult();
        }
        finally {
            PMF.endTransaction();
        }
    }

    public Class<RTCDeleteEventsAction> getActionType() {
        return RTCDeleteEventsAction .class;
    }


}